package com.duanjw.springframework.servlet;

import com.duanjw.springframework.FileUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class MyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String basePath = MyServlet.class.getResource("/").getPath();
        String requestURI = req.getRequestURI();

        String path = basePath + requestURI;


        File file = new File(path);

        FileUtils.writeFile(file,resp.getOutputStream());
//        super.doGet(req, resp);
    }
}
